﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using SnailGame.Utility.DataAccess;

namespace Com.Crc.ResManage.DAL.EquipManage
{
    public class SubDistrictManageDAL
    {
        DataBroker broker = new DataBroker();

        /// <summary>
        /// 查询小区信息
        /// </summary>
        /// <param name="strBranchID">分局ID</param>
        /// <param name="strSubDistrictID">小区ID</param>
        /// <returns></returns>
        public DataTable QuerySubdistrictData(string strBranchID, string strSubDistrictID)
        {
            string strSql = @" SELECT a.N_ID,b.N_NO,a.S_NAME,a.N_COVG_ID,a.N_CONTENT_ID,a.N_PARENT_ID,a.N_BUSNIESSDEPARTMENT,
                                      a.N_AREA_ID,a.S_ARRRESS,a.D_START,a.N_HOURSE_TYPE_ID,a.N_HOURSE_NUM,a.N_HOURSE_FAMILY,a.N_L_BOX_NUM,a.N_L_MACHINE_NUM,
                                      a.N_L_INFO,a.N_A_BOX_NUM,a.N_B_BOX_NUM,a.N_HL_HC_BOX_NUM,N_PON_NUM,S_ESTATE_CONTACTER,
                                      a.S_ESTATE_PHONE,S_MH_TROOPS,S_MH_MAINPERSON,S_BAK,S_STATE,D_CREATE,D_MODIFY 
                                 FROM TT_RESOURCE_SUBDISTRICT a
                           INNER JOIN TT_RESOURCE_SUBSTATION b ON a.N_SUBSTATION_ID = b.N_ID
                                WHERE a.S_STATE='1' ";
            if (strBranchID != "")
            {
                strSql += " AND a.N_PARENT_ID = " + strBranchID;
            }
            if (strSubDistrictID != "")
            {
                strSql += " AND a.N_ID = " + strSubDistrictID;
            }
            return broker.ExecuteQueryForOleDB(strSql, ConfigurationManager.ConnectionStrings["CRCAppConn"].ToString());
        }
    }
}
